package com.copa.config;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
 * @author copa
 * @createDate 2021-02-24 12:52
 * @function 七牛云配置
 */
@Configuration
public class QiniuConfig {
    public static String ACCESS_KEY;
    public static String SECRET_KEY;
    public static String BUCKET;
    public static String CDN_URL;


    @Value("${qiniu.accessKey}")
    public void setAccessKey(String accessKey) {
        ACCESS_KEY = accessKey;
    }

    @Value("${qiniu.secretKey}")
    public void setSecretKey(String secretKey) {
        SECRET_KEY = secretKey;
    }

    @Value("${qiniu.bucket}")
    public void setBUCKET(String bucket) {
        BUCKET = bucket;
    }

    @Value("${qiniu.cdnUrl}")
    public void setCdnUrl(String cdnUrl) {
        CDN_URL = cdnUrl;
    }

    public static String wirePic(String path){
        if(StringUtils.isBlank(path)){
            return null;
        }
        return CDN_URL + path;
    }
}